package com.zdp.oauth.controller;

import com.zdp.oauth.entity.oauth.LoginUserInfo;
import com.zdp.oauth.entity.vo.ResultInfo;
import com.zdp.oauth.filter.AccessContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author sesshomaru
 * @date 2022/5/24
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private HttpServletRequest httpServletRequest;

    /**
     * <h2>拦截器解析jwt token获取用户信息后存储请求上下文,测试获取</h2>
     */
    @GetMapping("/user-info-by/parse/jwt/token")
    public ResultInfo<LoginUserInfo> getCurrentUserInfo() {
        return new ResultInfo<LoginUserInfo>(200, "", httpServletRequest.getServletPath(), AccessContext.getLoginUserInfo());
    }
}
